'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
		<title>Google Maps JavaScript API Example: Simple Map</title>
		<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=" type="text/javascript"></script>
		<script type="text/javascript">
			var map;
			var geocoder; 
			var msg ;
			function initialize() {
				if (GBrowserIsCompatible()) {
					map = new  GMap2(document.getElementById("map_canvas"));
					map.addControl(new GLargeMapControl());
					map.addControl(new GMapTypeControl());
					map.addControl(new GScaleControl());
					map.addControl(new GOverviewMapControl());
					map.setCenter(new GLatLng(31.573636,107.112648, 12, G_NORMAL_MAP));
		  		map.enableContinuousZoom();
		  		map.enableScrollWheelZoom();  
		  		geocoder = new GClientGeocoder();

		  	  GEvent.addListener(map, "click",
		  	     function(overlay, latlng) {        
		  	     	if (latlng) {  
        				document.getElementById("LatValue").value = latlng.lat();
       					document.getElementById("LngValue").value = latlng.lng();
       					document.getElementById("EventName").value = "click" ;
       				}
       			  //PutMarker(document.getElementById("LatValue").value, document.getElementById("LngValue").value,"")
            }
 					);

 					/*
 					GEvent.addListener(map, "mousemove",
		  	    function(latlng){
        		  document.getElementById("LatValue").value = latlng.lat();
       			  document.getElementById("LngValue").value = latlng.lng();
       			  document.getElementById("EventName").value = "mousemove" ;
       			  //PutMarker(document.getElementById("LatValue").value, document.getElementById("LngValue").value,"")
            }
 					);
 					*/				
		  	}
			};
			
			function createMarker(point, number,msg) {
				var marker = new GMarker(point);
				marker.value = number;
				GEvent.addListener(marker, "click", function() {
					var myHtml = "<b>#" + number + "</b><br/>" + msg;
					map.openInfoWindowHtml(point, myHtml);
				});
				return marker;
			}
			
			function showrandommarker(count){
				var bounds = map.getBounds();
				var southWest = bounds.getSouthWest();
				var northEast = bounds.getNorthEast();
				var lngSpan = northEast.lng() - southWest.lng();
				var latSpan = northEast.lat() - southWest.lat();
				for (var i = 0; i < count; i++) {
					  var point = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random());
					  map.addOverlay(createMarker(point, i + 1, "abcdef"));
				}
			}
			
			function addployline(){
				var polyline = new GPolyline([new GLatLng(39.907,116.387), new GLatLng(39.935,126.407), new GLatLng(49.935,126.407)], "#ff0000", 3);  
				map.addOverlay(polyline);
			}
			
			function PutMarker(Lat, Lang, Msg) {
				  var latlng = new google.maps.LatLng(Lat,Lang);
				  var marker = new google.maps.Marker({
				      position: latlng,
				      map: map,
				      title: Msg+" ("+Lat+","+Lang+")"
				  });
				  
			    //把建立的标记保存在数据中
			    markersArray.push(marker);
			  
			    //计算关联的图片的索引
			    index= (markersArray.length % 10);
			    if (index==0) { index=10 }
			    icon = "http://www.google.com/mapfiles/kml/paddle/"+index+"-lv.png";
			    marker.setIcon(icon);
			}
			
			

			function getAddress(overlay, latlng) {
			  if (latlng != null) {
			    address = latlng;
			    geocoder.getLocations(latlng, showAddress);
			  }
			}
			
			function showAddress(response) {
			  //map.clearOverlays();
			  if (!response || response.Status.code != 200) {
			    //alert("Status Code:" + response.Status.code);
			    document.getElementById("Renvrse").value = "" ;
			  } else {
			    place = response.Placemark[0];
			    point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
			    //marker = new GMarker(point);
			    //map.addOverlay(marker);		    
			    document.getElementById("Renvrse").value = place.address ;
			    /*
			    map.openInfoWindowHtml(
			        '&lt;b&gt;orig latlng:&lt;/b&gt;' + response.name + '&lt;br/&gt;' + 
			        '&lt;b&gt;latlng:&lt;/b&gt;' + place.Point.coordinates[0] + "," + place.Point.coordinates[1] + '&lt;br&gt;' +
			        '&lt;b&gt;Status Code:&lt;/b&gt;' + response.Status.code + '&lt;br&gt;' +
			        '&lt;b&gt;Status Request:&lt;/b&gt;' + response.Status.request + '&lt;br&gt;' +
			        '&lt;b&gt;Address:&lt;/b&gt;' + place.address + '&lt;br&gt;' +
			        '&lt;b&gt;Accuracy:&lt;/b&gt;' + place.AddressDetails.Accuracy + '&lt;br&gt;' +
			        '&lt;b&gt;Country code:&lt;/b&gt; ' + place.AddressDetails.Country.CountryNameCode );
 					*/
			  }
			}			
			

		</script>
	</head>
	<body onload="initialize()" onunload="GUnload()">
		<div id="map_canvas" style="position:absolute;left:0;top:0;width:100%;height:100%;"></div>
		<div id="latlong">
      <input type="hidden" id="LatValue" >
      <input type="hidden" id="LngValue" >
      <input type="hidden" id="EventName">
      <input type="hidden" id="Renvrse">
    </div>
	</body>
</html>